<?php

namespace app\admin\validate;

use think\Validate;

class Autoplan extends Validate
{

    /**
     * 验证规则
     */
    protected $rule = [
        //'week' => 'require|regex:.{8,40}|unique:admin,week',
    ];

    protected function checkDistrictId($value, $rule, $data)
    {
        if ($data['city_id']== '0') {
            return true;
        }
        if($value==""||$value=="-1"){
            return false;
        }
        return true;
    }

    /**
     * 提示消息
     */
    protected $message = [];

    /**
     * 字段描述
     */
    protected $field = [];

    /**
     * 验证场景
     */
    protected $scene = [
        'add' => [
            'name' => 'require|regex:.{8,40}|unique:school,name',
            'address' => 'require',
        ],
        'edit' => [
            'name' => 'require|regex:.{8,40}',
            //'address' => 'require',
        ]
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            //'week' => "周几",
        ];
        $this->message = array_merge($this->message, [
            //'week.regex' => '周几格式错误',
            //'week.require' => '周几必选',
        ]);
        parent::__construct($rules, $message, $field);
    }

}
